package com.gxuwz.stats.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxuwz.stats.entity.DecisionConsulting;
import com.gxuwz.stats.entity.NetworkCulture;
import com.gxuwz.stats.entity.User;
import com.gxuwz.stats.mapper.NetworkCultureMapper;
import com.gxuwz.stats.mapper.UserMapper;
import com.gxuwz.stats.service.NetworkCultureService;
import com.gxuwz.stats.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NetworkCultureServiceImpl extends ServiceImpl<NetworkCultureMapper, NetworkCulture> implements NetworkCultureService {

    @Autowired
    private UserService userService;

    /**
     *
     * @param page
     * @param queryWrapper
     * @return
     */
    @Override
    public IPage<NetworkCulture> getNetworkCultureList(IPage<NetworkCulture>  page, QueryWrapper<NetworkCulture> queryWrapper){
        IPage<NetworkCulture> resultPage = this.page(page,queryWrapper);
        for(NetworkCulture networkCulture : resultPage.getRecords()){
            Integer userId = networkCulture.getUserId();
            if(userId != null){
                User user = userService.getById(userId);
                if(user != null){
                    networkCulture.setUsername(user.getUsername());
                }
            }
        }
        return  resultPage;
    }
}
